package com.purong.purong.activity;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;


import com.purong.purong.R;
import com.purong.purong.adapter.CreditItemDetAdapter;
import com.purong.purong.bean.CreditDetBean.CreditDetItem;
import com.purong.purong.widget.FullyLinearLayoutManager;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by wenjiezeng on 2017/9/25.
 * 信用卡专属特权详情
 */
public class CreditItemDetActivity extends BaseActivity{
    private TextView title;
    private TextView interOne,interTwo,interThree,interFour,interFive,interSix;
    private String titleName;
    private RecyclerView mRecyclerView;
    private CreditItemDetAdapter mAdapter;
    private List<CreditDetItem> itemList = new ArrayList<>();
    private List<String> interestString=new ArrayList<>();
    @Override
    public void initBundle() {
        titleName=getIntent().getStringExtra("TITLE");
        itemList=(ArrayList)getIntent().getSerializableExtra("ITEM_LIST");
        interestString=(ArrayList)getIntent().getSerializableExtra("INTEREST_LIST");
    }

    @Override
    public int getRootViewId() {
        return R.layout.activity_credit_item_detial;
    }

    public void initView(){
        interOne=(TextView)findViewById(R.id.interest_one);
        interTwo=(TextView)findViewById(R.id.interest_two);
        interThree=(TextView)findViewById(R.id.interest_three);
        interFour=(TextView)findViewById(R.id.interest_four);
        interFive=(TextView)findViewById(R.id.interest_five);
        interSix=(TextView)findViewById(R.id.interest_six);

        title=(TextView)findViewById(R.id.title);
        if (titleName!=null){
            title.setText(titleName);
        }
        mRecyclerView=(RecyclerView)findViewById(R.id.recycler_view);
        if (itemList!=null){
            mAdapter=new CreditItemDetAdapter(this);
            if (titleName.equals("优惠活动"))
                mAdapter.setYhhd(true);
            mAdapter.setData(itemList);
            mRecyclerView.setLayoutManager(new FullyLinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
            mRecyclerView.setAdapter(mAdapter);
        }
        if (titleName.equals("费用信息")&&interestString!=null&&interestString.size()==6){
            findViewById(R.id.interest_title).setVisibility(View.VISIBLE);
            findViewById(R.id.interest_lay).setVisibility(View.VISIBLE);
            interOne.setText(interestString.get(0)+"%");
            interTwo.setText(interestString.get(1)+"%");
            interThree.setText(interestString.get(2)+"%");
            interFour.setText(interestString.get(3)+"%");
            interFive.setText(interestString.get(4)+"%");
            interSix.setText(interestString.get(5)+"%");
        }
    }

    @Override
    public void initData() {

    }

    public void onClick(View v){
        switch (v.getId()){
            case R.id.close:
                this.finish();
                break;
        }
    }
}
